<?php


namespace app\app\controller;


use EasyWeChat\Factory;
use think\Db;

class Shop extends WxUser
{
    protected $shopInfo;
    protected $shopId;
    protected $employInfo;
    protected $employId;

    protected function initialize()
    {
        parent::initialize();
        $role_name = $this->getMemberRole2();
        if ($role_name['code'] == 1) {
            responseJson(-300, '您不是管理端人员');
        }
        if ($role_name['code'] == 3 || $role_name['code'] == 4) {
            $employ_info = Db::name('employ')->where([
                'member_id' => $this->memberId,
                'is_del' => 0
            ])->find();
            $this->employInfo = $employ_info;
            $this->employId = $employ_info['id'];
        }
        $shop = Db::name('shop')
            ->where(['is_del' => 0])
            ->find();
        $this->shopInfo = $shop;
        $this->shopId = $shop['id'];
    }

    //获取商户信息
    public function getShopInfo()
    {
        //todo 发布生成添加员工的二维码 生成路径
        if (!$this->shopInfo['code_url']) {
            $code_url = qrcode($this->shopId, 'pages1/staffMessage/staffMessage');
            Db::name('shop')->update([
                'id' => $this->shopId,
                'code_url' => $code_url
            ]);
            $this->shopInfo['code_url'] = $code_url;
        }
        msg(0, '查询完成', $this->shopInfo);
    }

    //获取员工信息
    public function getEmployInfo()
    {
        msg(0, '查询完成', $this->employInfo);
    }

    //店铺管理顶部3个
    public function orderNum()
    {
        //delive_type  1快递发货 2同城配送 3到店自提
        //status       1待支付 2待发货 3待收货 4待核销 5已完成 6已评价 7已取消 8退款售后 9待配送
        //  待核销 待发货 待配送
        $a = Db::name('order')->where([
            ['status', 'in', [4]],
            ['pay_status','=',1],
            ['delive_type', 'in', [3]],
            ['is_del', '=', 0]
        ])->count();
        $b = Db::name('order')->where([
            ['status', 'in', [2]],
            ['pay_status','=',1],
            ['delive_type', 'in', [1]],
            ['is_del', '=', 0]
        ])->count();
        $c = Db::name('order')->where([
            ['status', 'in', [9]],
            ['delive_type', 'in', [2]],
            ['pay_status','=',1],
            ['is_del', '=', 0]
        ])->count();
        $return_data['a'] = $a;
        $return_data['b'] = $b;
        $return_data['c'] = $c;
        msg(0, '查询完成', $return_data);
    }

    //最近7天交易数量
    public function saleCountList()
    {
        //status       1待支付 2待发货 3待收货 4待核销 5已完成 6已评价 7已取消 8退款售后
        $order_where[] = ['status', 'in', [2, 3, 4, 5, 6]];
        $order_where[] = ['is_del', '=', 0];
        $order_num = 0;
        for ($i = 7; $i >= 1; $i--) {
            $daysAgo[] = date('m.d', strtotime(-$i . " days"));
            $timescope = getTimestamp(-$i);
            $num = Db::name('order')
                ->where('pay_time', 'between', [$timescope[0], $timescope[1]])
                ->where($order_where)
                ->count();
            $day_order_num[] = $num;
            $order_num += $num;
        }
        $data['date'] = $daysAgo;
        $data['num'] = $day_order_num;
        $data['order_num'] = $order_num;
        msg(0, '', $data);
    }


    //修改商户信息
    public function editShopInfo()
    {
        $data = $this->request->param();
        $update_data = array(
            'id' => $this->shopId,
            'address' => $data['address'],
            'people' => $data['people'],
            'phone' => $data['phone'],
            'latitude' => $data['latitude'],
            'longitude' => $data['longitude'],
        );
        $data_list = getAddressByLocation2($data['latitude'], $data['longitude']);
        $data_list = json_decode($data_list, true);
        if ($data_list['code'] == 0) {
            $address_info = $data_list['data']['address_component'];
            $update_data['province'] = $address_info['province'];
            $update_data['city'] = $address_info['city'];
            $update_data['area'] = $address_info['district'];
        }
        Db::startTrans();
        try {
            $business2_id = Db::name('shop')->update($update_data);
            Db::commit();
            msg(0, '查询成功', $this->shopInfo);
        } catch (\Exception $e) {
            Db::rollback();
            msg(-1, $e->getMessage(), '');
        }
    }

    //核销订单列表
    public function getOrderList()
    {

        $data = $this->request->param();
        $page = input('page/d', 1);
        $length = input('limit/d', 20);
        $time = $data['time'];
        $where[] = ['o.shop_id', '=', $this->shopId];
        if (isset($time) && $time) {
            $order_time = getStrtoTime($time);
            $where[] = ['o.pay_time', '<=', $order_time[1]];
        }

        //1待支付 2待发货 3待收货 4已完成 5已评价 6售后退货
        //7已取消 8待取货 9拼团待完成10砍价发起
        if ($data['type'] == 0) {
            $where[] = ['o.status', 'in', [4, 5, 8]];
        }
        if ($data['type'] == 1) {
            $where[] = ['o.status', 'in', [8]];
        }
        if ($data['type'] == 2) {
            $where[] = ['o.status', 'in', [4, 5]];
        }
        $order_list = Db::name('order')->alias('o')
            ->join('order_goods og', 'og.order_id=o.id')
            ->field('o.*,og.suk,og.goods_id,og.num,og.price,og.goods_name,og.goods_img,og.sum_money')
            ->where($where)
            ->order('create_time desc')
            ->paginate($length, false, ['page' => $page])
            ->each(function ($item) {
//                if (!$item['shop_get_money'] == 0) {
//                    $goods_info=Db::name('goods')->find($item['goods_id']);
//                    $item['shop_get_money']=$item['sum_money']*($goods_info['shop_return']/100);
//                }
                $item['member_info'] = Db::name('member')->find($item['member_id']);
                $item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
                return $item;
            });
        msg(0, "查询成功", $order_list);
    }

    //核销码核销
    public function verifyOrderDigits()
    {
        $data = $this->request->param();
        $order_id = $data['order_id'];
        $write_code_digits = $data['write_code_digits'];
        Db::startTrans();
        try {
            $result = verifyGoodsOrder($order_id, 2, $this->shopId, $write_code_digits, $this->memberId);
            Db::commit();
            msg(0, '核销完成', $result);
        } catch (\Exception $e) {
            Db::rollback();
            msg(-1, $e->getMessage(), '');
        }
    }

    //商家扫码核销
    public function verifyOrder()
    {
        $data = $this->request->param();
        Db::startTrans();
        try {
            $order_id = $data['order_id'];
            $result = verifyGoodsOrder($order_id, 1, $this->shopId, '', $this->memberId);
            Db::commit();
            msg(0, '核销完成', $result);
        } catch (\Exception $e) {
            Db::rollback();
            msg(-1, $e->getMessage(), '');
        }
    }

    public function orderDetail()
    {
        $data = $this->request->param();
        $return_detail = Db::name('order')->find($data['id']);
        Db::startTrans();
        try {
            $config = config('wechat.wxpay');
            $app = Factory::payment($config);
            $res = $app->order->queryByOutTradeNumber($data['id']);
            if ($res['trade_state'] == "SUCCESS") {
                PtOrderPaySuccess2($return_detail);
                $return_detail = Db::name('order')->where('order_no', '=', $data['id'])->find();
            }
            if (!$return_detail) {
                msg(-1, '订单不存在', '');
            }
            $return_detail['create_time'] = date('Y-m-d H:i:s', $return_detail['create_time']);
            if ($return_detail['pay_time']) {
                $return_detail['pay_time'] = date('Y-m-d H:i:s', $return_detail['pay_time']);
            }
            if ($return_detail['tui_time']) {
                $return_detail['tui_time'] = date('Y-m-d H:i:s', $return_detail['tui_time']);
            }
            if ($return_detail['send_time']) {
                $return_detail['send_time'] = date('Y-m-d H:i:s', $return_detail['send_time']);
            }
            $order_goods = Db::name('order_goods')
                ->where('order_id', '=', $return_detail['id'])
                ->select();
            $return_detail['order_goods'] = $order_goods;
//            if ($return_detail['delive_type'] == 2) { //不再过滤订单类型
            if (!$return_detail['write_code']) {
                $write_code_digits = rand(1000, 9999);
                //todo 订单路径 pages/order/orderDetails/orderDetails
                $qr_code = qrcode($return_detail['id'], 'pages1/cancelPage/cancelPage');
                $update_order = array(
                    'id' => $return_detail['id'],
                    'write_code' => $qr_code,
                    'write_code_digits' => $write_code_digits
                );
                Db::name('order')->update($update_order);
                $return_detail['write_code'] = $qr_code;
                $return_detail['write_code_digits'] = $write_code_digits;
            }
//            }
            $shop_info = Db::name('shop')->find($return_detail['shop_id']);
            $return_detail['shop_info'] = $shop_info;
            Db::commit();
            msg(0, '查询成功', $return_detail);
        } catch (\Exception $e) {
            Db::rollback();
            msg(-1, $e->getMessage(), '');
        }
    }

    //商品列表
    public function goodsList()
    {
        $data = $this->request->param();
        $page = input('page/d', 1);
        $length = input('limit/d', 20);
        $where[] = ['is_del', '=', 0];
        //type 1售卖中 2仓库中
        //status 0下架1上架
        if (isset($data['goods_name']) && $data['goods_name']) {
            $where[] = ['name', 'like', '%' . $data['goods_name'] . '%'];
        }
        if (isset($data['type']) && $data['type']) {
            if ($data['type'] == 1) {
                $where[] = ['status', '=', 1];
            } else {
                $where[] = ['status', '=', 0];
            }
        }
        if (isset($data['cate_id']) && $data['cate_id']) {
            $where[] = ['cate_id', '=', $data['cate_id']];
        }
        $data_list = Db::name('goods')
            ->where($where)->order('sort desc')
            ->paginate($length, false, ['page' => $page])->each(function ($item) {
                $goods_attr_value = Db::name('goods_attr_value')->where([
                    'is_del' => 0,
                    'goods_id' => $item['id']
                ])->find();
                $item['goods_attr_value'] = $goods_attr_value;
                $item['stock'] = $goods_attr_value['stock'];
                return $item;
            });
        msg(0, '查询成功', $data_list);
    }

    //删除商品
    public function delGoods()
    {
        $data = $this->request->param();
        Db::startTrans();
        try {
            $update_date = Db::name('goods')->update([
                'id' => $data['goods_id'],
                'is_del' => 1
            ]);
            Db::commit();
            msg(0, '查询成功', $update_date);
        } catch (\Exception $e) {
            Db::rollback();
            msg(-1, $e->getMessage(), '');
        }
    }

    //上架、下架商品
    public function setGoodsStatus()
    {
        $data = $this->request->param();
        //status 0下架1上架
        Db::startTrans();
        try {
            $update_date = Db::name('goods')->update([
                'id' => $data['goods_id'],
                'status' => $data['status']
            ]);
            Db::commit();
            msg(0, '查询成功', $update_date);
        } catch (\Exception $e) {
            Db::rollback();
            msg(-1, $e->getMessage(), '');
        }
    }

    //创建商品
    public function createGoods()
    {
        //img
        //goods_name
        //price old_price stock sale_num
        //detail  sort cate_id
        // goods_attr_list array
        $data = $this->request->param();
        Db::startTrans();
        try {
            $data['is_spec'] = 0;
            $insert_date = array(
                'cate_id' => $data['cate_id'],
                'brand_id' => $data['brand_id'],
                'name' => $data['name'],
                'img' => $data['img'],
//                'detail' => $data['detail'],
                'create_time' => time(),
                'is_spec' => $data['is_spec'],
                'sale_num' => $data['sale_num'],
                'sort' => $data['sort'],
            );

            if (isset($data['detail']) && $data['detail']) {
                $insert_date['detail'] = implode(',', $data['detail']);
            }

//            $insert_date['first_img'] = $first_img[0];
            $insert_date['first_img'] = $data['img'];
            $goods_id = Db::name('goods')->insertGetId($insert_date);
            if (isset($data['goods_attr_list']) && $data['goods_attr_list']) {
                foreach ($data['goods_attr_list'] as $k => $v) {
                    if ($v['name']) {
                        $insert_data2 = array(
                            'goods_id' => $goods_id,
                            'name' => $v['name'],
                            'value' => $v['value'],
                            'sort' => $k + 1
                        );
                        Db::name('goods_attribute_value')->insertGetId($insert_data2);
                    }
                }
            }

            $goods_attr_insert_data = array(
                'goods_id' => $goods_id,
                'attr_name' => '规格',
                'attr_value' => '默认',
            );
            $goods_attr_value_insert_data = array(
                'goods_id' => $goods_id,
                'suk' => '默认',
                'stock' => $data['stock'],
                'price' => $data['price'],
                'price2' => $data['price'],
                'old_price' => $data['old_price'],
            );
            $goods_attr_id = Db::name('goods_attr')
                ->insertGetId($goods_attr_insert_data);
            $goods_attr_value_id = Db::name('goods_attr_value')
                ->insertGetId($goods_attr_value_insert_data);
            Db::commit();
            msg(0, '添加完成', $goods_id);
        } catch (\Exception $e) {
            Db::rollback();
            msg(-1, $e->getMessage(), '');
        }
    }

    //编辑商品
    public function editGoods()
    {
        $data = $this->request->param();
        Db::startTrans();
        try {
            $data['is_spec'] = 0;
            $insert_date = array(
                'id' => $data['goods_id'],
                'cate_id' => $data['cate_id'],
                'brand_id' => $data['brand_id'],
                'name' => $data['name'],
                'img' => $data['img'],
//                'detail' => $data['detail'],
                'create_time' => time(),
                'is_spec' => $data['is_spec'],
                'sale_num' => $data['sale_num'],
                'sort' => $data['sort'],
            );
            if (isset($data['detail']) && $data['detail']) {
                $insert_date['detail'] = implode(',', $data['detail']);
            }
//            $insert_date['detail']= explode(',', $data['detail']);
//            $first_img = explode(',', $data['img']);
//            $insert_date['first_img'] = $first_img[0];
            $insert_date['first_img'] = $data['img'];
            $goods_id = Db::name('goods')->update($insert_date);
            if (isset($data['goods_attr_list']) && $data['goods_attr_list']) {
                Db::name('goods_attribute_value')
                    ->where('goods_id', '=', $data['goods_id'])
                    ->delete();
                foreach ($data['goods_attr_list'] as $k => $v) {
                    if ($v['name']) {
                        $insert_data2 = array(
                            'goods_id' => $goods_id,
                            'name' => $v['name'],
                            'value' => $v['value'],
                            'sort' => $k + 1
                        );
                        Db::name('goods_attribute_value')->insertGetId($insert_data2);
                    }
                }
            }
            Db::name('goods_attr_value')->where([
                'goods_id' => $data['goods_id'],
            ])->update([
                'price' => $data['price'],
                'price2' => $data['price'],
                'old_price' => $data['old_price'],
                'stock' => $data['stock'],
            ]);
            Db::commit();
            msg(0, '修改完成', $goods_id);
        } catch (\Exception $e) {
            Db::rollback();
            msg(-1, $e->getMessage(), '');
        }
    }

    //待核销列表
    public function verityOrderListD()
    {
        $data = $this->request->param();
        $page = input('page/d', 1);
        $length = input('limit/d', 20);
        $where[] = ['is_del', '=', 0];
        $where[] = ['delive_type', '=', 3];
        $where[] = ['status', '=', 4];
        $where[] = ['write_status', '=', 0];
        $data_list = Db::name('order')
            ->where($where)->order('pay_time desc')
            ->paginate($length, false, ['page' => $page])->each(function ($item) {
                $item['pay_time'] = date('Y-m-d H:i:s', $item['pay_time']);
                $order_goods = Db::name('order_goods')
                    ->where('order_id', '=', $item['id'])
                    ->select();
                $item['order_goods'] = $order_goods;
                return $item;
            });
        msg(0, '查询成功', $data_list);
    }

    //核销记录列表
    public function verityOrderList()
    {
        $data = $this->request->param();
        $page = input('page/d', 1);
        $length = input('limit/d', 20);
        $where[] = ['is_del', '=', 0];
        $where[] = ['delive_type', '=', 3];
        $where[] = ['write_status', '=', 1];
        $data_list = Db::name('order')
            ->where($where)->order('finish_time desc')
            ->paginate($length, false, ['page' => $page])->each(function ($item) {
                $item['finish_time'] = date('Y-m-d H:i:s', $item['finish_time']);
                $order_goods = Db::name('order_goods')
                    ->where('order_id', '=', $item['id'])
                    ->select();
                $item['order_goods'] = $order_goods;
                return $item;
            });
        msg(0, '查询成功', $data_list);
    }

    // 订单修改
    //订单列表 type    0全部  1待发货 2待配送  3待核销 4待收货 5已完成
    //        status 1待支付 2待发货  3待收货 4待核销 5已完成 6已评价 7已取消 8退款售后 9待配送
    public function orderList()
    {
        $data = $this->request->param();
        $page = input('page/d', 1);
        $length = input('limit/d', 20);
        $where[] = ['is_del', '=', 0];
        if ($data['type'] == 0) {
            $where[] = ['status', 'in', [2, 3, 4, 5, 6, 9]];
        }
        if (isset($data['type']) && $data['type']) {
            if ($data['type'] == 1) {
                $where[] = ['status', 'in', [2]];
            }
            if ($data['type'] == 2) {
                $where[] = ['status', 'in', [9]];
            }
            if ($data['type'] == 3) {
                $where[] = ['status', 'in', [4]];
            }
            if ($data['type'] == 4) {
                $where[] = ['status', 'in', [3]];
            }
            if ($data['type'] == 5) {
                $where[] = ['status', 'in', [5, 6]];
            }
        }
        $order_list = Db::name('order')
            ->where($where)
            ->order('create_time desc')
            ->paginate($length, false, [
                'page' => $page
            ])->each(function ($item) {
                $item['create_time2'] = $item['create_time'];
                $item['dai_zf_time1'] = $item['create_time'] + (60 * 15);
                $item['dai_zf_time'] = date('Y-m-d H:i:s', $item['create_time'] + (60 * 15));
                $item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
                if ($item['pay_time']) {
                    $item['pay_time'] = date('Y-m-d H:i:s', $item['pay_time']);
                }
                if ($item['tui_time']) {
                    $item['tui_time'] = date('Y-m-d H:i:s', $item['tui_time']);
                }
                $order_goods = Db::name('order_goods')
                    ->where('order_id', '=', $item['id'])
                    ->select();
                $item['order_goods'] = $order_goods;
                return $item;
            });
        msg(0, '查询成功', $order_list);
    }

    //商家设置
    public function setShopInfo()
    {
        $data = $this->request->param();
        Db::startTrans();
        try {
            $update = array(
                'id' => 1,
                'shop_name' => $data['shop_name'] ? $data['shop_name'] : $this->shopInfo['shop_name'],
                'province' => $data['province'] ? $data['province'] : $this->shopInfo['province'],
                'city' => $data['city'] ? $data['city'] : $this->shopInfo['city'],
                'area' => $data['area'] ? $data['area'] : $this->shopInfo['area'],
                'address' => $data['address'] ? $data['address'] : $this->shopInfo['address'],
                'phone' => $data['phone'] ? $data['phone'] : $this->shopInfo['phone'],
                'express_money' => $data['express_money'] ? $data['express_money'] : $this->shopInfo['express_money'],
            );
            $address = getLWByAddress($data['province'] . $data['city'] . $data['area'] . $data['address']);
            $address = json_decode($address, true);
            if ($address['code'] == 0) {
                $update['longitude'] = $address['data'][0];
                $update['latitude'] = $address['data'][1];
            }
            $order_data = Db::name('shop')->update($update);
            Db::commit();
            msg(0, "设置完成", $order_data);
        } catch (\Exception $e) {
            Db::rollback();
            msg(-1, $e->getMessage(), '');
        }
    }

    //分类详情
    public function cateDetail()
    {
        $data = $this->request->param();
        $return_date = Db::name('goods_cate')->find($data['id']);
        msg(0, "支付成功！", $return_date);
    }

    //删除分类
    public function delCate()
    {
        $data = $this->request->param();
        Db::name('goods_cate')->update([
            'id' => $data['id'],
            'is_del' => 1,
        ]);
        msg(0, '', 1);
    }

    //设置分类
    public function setCate()
    {
        $data = $this->request->param();
        Db::startTrans();
        try {
            $update_date = array(
                'id' => $data['id'],
                'name' => $data['name'],
//                'status' => $data['status'],
                'status' => 1,
                'img' => $data['img'],
//                'sort' => $data['sort'],
                'sort' => 10,
            );
            $update_data = Db::name('goods_cate')->update($update_date);
            Db::commit();
            msg(0, '创建完成', $update_data);
        } catch (\Exception $e) {
            Db::rollback();
            msg(-1, $e->getMessage(), '');
        }
    }

    //创建分类
    public function addCate()
    {
        $data = $this->request->param();
        Db::startTrans();
        try {
            $add_date = array(
                'name' => $data['name'],
//                'status' => $data['status'],
                'status' => 1,
                'img' => $data['img'],
//                'sort' => $data['sort'],
                'sort' => 10,
            );
            $add_date_id = Db::name('goods_cate')->insertGetId($add_date);
            Db::commit();
            msg(0, '创建完成', $add_date_id);
        } catch (\Exception $e) {
            Db::rollback();
            msg(-1, $e->getMessage(), '');
        }
    }

    //员工管理
    public function getEmployList()
    {
        $data = $this->request->param();
        $page = input('page/d', 1);
        $length = input('limit/d', 10);
        $where[] = ['e.is_del', '=', 0];
        $data_list = Db::name('employ')->alias('e')
            ->join('member m', 'e.member_id=m.id')
            ->field('e.*,m.avatarUrl')
            ->where($where)
            ->order('role')
            ->order('create_time desc')
            ->paginate($length, false, [
                'page' => $page
            ])
            ->each(function ($item) {
                return $item;
            });
        msg(0, '更改成功', $data_list);
    }

    //设置超级员工 取消超级员工
    public function setManage()
    {
        $data = $this->request->param();
        $employ_info = Db::name('employ')->find($data['employ_id']);
//        if ($employ_info['business_id'] != $this->shopId) {
//            msg(-1, '员工不属于本商家', '');
//        }
        $update = array(
            'id' => $data['employ_id'],
            'role' => $data['role'] //1普通员工 2管理员
        );
        Db::name('employ')->update($update);
        msg(0, '更改成功', $data['operation_status']);
    }

    //删除员工
    public function delEmploy()
    {
        $data = $this->request->param();
        $employ_info = Db::name('employ')->find($data['employ_id']);
//        if ($employ_info['business_id'] != $this->shopId) {
//            msg(-1, '员工不属于本商家', '');
//        }
        $update = array(
            'id' => $data['employ_id'],
            'is_del' => 1
        );
        Db::name('employ')->update($update);
        msg(0, '更改成功', $data['operation_status']);
    }
    //快递订单发货
    //1待支付 2待发货 3待收货 4待核销 5已完成 6已评价 7已取消 8退款售后 9待配送
    public function send()
    {
        Db::startTrans();
        try {
            $data = $this->request->param();
            $order_id = $data['order_id'];
            $num = Db::name('order')->update([
                'id' => $order_id,
                'status' => 3,
                'express_time' => time(),
                'express_no' => $data['express_no'],
                'express_name' => $data['express_name'],
            ]);
            Db::commit();
            msg(0, "发货完成", $num);
        } catch (\Exception $e) {
            Db::rollback();
            msg(-1, $e->getMessage(), '');
        }
    }

    //跑腿发货
    public function send2()
    {
        Db::startTrans();
        try {
            $data = $this->request->param();
            $order_id = $data['order_id'];
            $num = Db::name('order')->update([
                'id' => $order_id,
                'status' => 3,
                'express_time' => time(),
                'express_no' => $data['express_no'],
            ]);
            Db::commit();
            msg(0, "发货完成", $num);
        } catch (\Exception $e) {
            Db::rollback();
            msg(-1, $e->getMessage(), '');
        }
    }
    //todo 汽配项目发布 后台 ，看物价，搭建后台 数据表

    //商品详情
    public function getGoodsDetail()
    {
        $data = $this->request->param();
        $goods_info = Db::name('goods')->find($data['id']);
        $brand = Db::name('brand')->find($goods_info['brand_id']);
        $goods_info['brand'] = $brand['name'];
        $img = explode(',', $goods_info['img']);
        $goods_info['img'] = $img;

        $detail = explode(',', $goods_info['detail']);
        $goods_info['detail'] = $detail;

        $goods_attr_value = Db::name('goods_attr_value')->where([
            'goods_id' => $data['id']
        ])->find();
        $goods_attribute_value = Db::name('goods_attribute_value')->where([
            'goods_id' => $data['id']
        ])->select();
        $goods_info['goods_attr_value'] = $goods_attr_value;
        $goods_info['goods_attribute_value'] = $goods_attribute_value;
        $goods_info['is_collect'] = $this->isCollect($data['id']);
        msg(0, '查询成功', $goods_info);
    }
    //todo 购物车商品数量 1
    // 大类列表 1
    // 商品大类搜索 1
    // 优惠多少钱 1
    // 个人信息返回 是否商家 几星 是游客 还是商家 1
    // 商家申请后 是一级商家 游客购买不再升级 商家身份才升级 2
    // 不是商家就是游客 商家分 1-3星 2
    // 嘉号通信后台 卡片导入 2
    // 大屏修改 2
    // 青岛汽配会员相关接口；心之悦 后台修改 增加分账角色；嘉号通信 下载代码备份 修改域名 数据库修改域名
}